<?php
	
	require_once(dirname(__FILE__) . "/../core/safeParam.php");
	
	global $database;
	
	 if(isset($_POST['funcion']) && $_POST['funcion'] == 'refresco'){
  		$consulta = $database->select("SELECT * FROM order_sum WHERE id = ". $_POST['id'] ." ");
  		echo $consulta[0]['status'];
  		exit();
  	}
	
	$infoUser	= $database->select("SELECT * FROM users WHERE id=". $_SESSION['userid'] ." ");
	$estado		= $database->select("SELECT order_sum.id, order_status.name, order_sum.date, order_sum.contents, order_sum.status, config.sitename
													FROM order_sum JOIN order_status ON order_sum.status=order_status.id JOIN config ON order_sum.rid = config.id
													WHERE order_sum.uid=". $_SESSION['userid']." ");
													
	$sinEstado	= $database->select("SELECT * FROM order_sum WHERE order_sum.uid=". $_SESSION['userid'] ." AND order_sum.status=0");
	
	if($estado){
		$smarty->assign('estado', $estado);
  	} else {
  		$smarty->assign('error', 1);
  	}
  	
  	if($sinEstado){
  		  	$smarty->assign("sinEstado", 1);
  	} else {
  		  	$smarty->assign("sinEstado", 0);	
  	}
  	  	
  	$smarty->assign("infoUsuario", $infoUser);

?>